/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot;

import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * 用于指示某个 Bean 在被包含于 {@link SpringApplication} 中时应当被<em>运行</em>的接口。
 * 在同一个应用上下文中可以定义多个 {@link CommandLineRunner} Bean，
 * 并且可以通过实现 {@link Ordered} 接口或使用 {@link Order @Order} 注解来指定执行顺序。
 * <p>
 * 如果你需要访问 {@link ApplicationArguments}（而不是原始的 String 数组），
 * 请考虑使用 {@link ApplicationRunner}。
 *
 * @author Dave Syer
 * @since 1.0.0
 * @see ApplicationRunner
 */
@FunctionalInterface
public interface CommandLineRunner {

	/**
	 * 用于运行该 Bean 的回调方法。
	 * @param args 传入 main 方法的参数
	 * @throws Exception 发生错误时抛出异常
	 */
	void run(String... args) throws Exception;

}
